home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 97 / CD-ROM 97 / CD-ROM 97.iso / internet / ghostzilla / ghsetup.exe / chrome / comm.jar / content / communicator / xpinstall / institems.js next >
Encoding:
JavaScript  |  2002-04-09  |  2.5 KB  |  93 lines

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "License"); you may not use this file except in
  5.  * compliance with the License. You may obtain a copy of the License at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the License is distributed on an "AS IS"
  9.  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
  10.  * License for the specific language governing rights and limitations
  11.  * under the License.
  12.  *
  13.  * The Original Code is Mozilla Communicator client code, released March
  14.  * 31, 1998.
  15.  *
  16.  * The Initial Developer of the Original Code is Netscape Communications
  17.  * Corporation. Portions created by Netscape are Copyright (C) 1998
  18.  * Netscape Communications Corporation. All Rights Reserved.
  19.  */
  20.  
  21. // dialog param block
  22. var gParam;
  23.  
  24. function addTreeItem(num, aName, aUrl)
  25. {
  26.   // first column is the package name
  27.   var item = document.createElement("description");
  28.   item.setAttribute("value", aName);
  29.   item.setAttribute("tooltiptext", aUrl);
  30.   item.setAttribute("class", "confirmName");
  31.  
  32.   // second column is the host serving the file
  33.   var urltext = aUrl.replace(/^([^:]*:\/*[^\/]+).*/, "$1");
  34.   var url = document.createElement('description');
  35.   url.setAttribute("value", aUrl);
  36.   url.setAttribute("tooltiptext", aUrl);
  37.   url.setAttribute("class", "confirmURL");
  38.   url.setAttribute("crop", "end");
  39.  
  40.   // create row and add it to the grid
  41.   var row  = document.createElement("row");
  42.   row.appendChild(item);
  43.   row.appendChild(url);
  44.  
  45.   document.getElementById("xpirows").appendChild(row);
  46. }
  47.  
  48.  
  49. function onLoad()
  50. {
  51.   var row = 0;
  52.   var moduleName, URL, numberOfDialogTreeElements;
  53.  
  54.   doSetOKCancel(onOk, onCancel);
  55.  
  56.   gParam = window.arguments[0].QueryInterface(Components.interfaces.nsIDialogParamBlock);
  57.  
  58.   gParam.SetInt(0, 1 ); /* Set the default return to Cancel */
  59.  
  60.   numberOfDialogTreeElements = gParam.GetInt(1);
  61.  
  62.   for (var i=0; i < numberOfDialogTreeElements; i++)
  63.   {
  64.     moduleName = gParam.GetString(i);
  65.     URL = gParam.GetString(++i);
  66.     addTreeItem(row++, moduleName, URL);
  67.   }
  68.  
  69.   var okText = document.getElementById("xpinstallBundle").getString("OK");
  70.   var okButton = document.getElementById("ok")
  71.   okButton.label = okText;
  72.   okButton.focus();
  73. }
  74.  
  75. function onOk()
  76. {
  77.    // set the okay button in the param block
  78.    if (gParam)
  79.      gParam.SetInt(0, 0 );
  80.  
  81.    window.close();
  82. }
  83.  
  84. function onCancel()
  85. {
  86.     // set the cancel button in the param block
  87.     if (gParam)
  88.       gParam.SetInt(0, 1 );
  89.  
  90.     window.close();
  91. }
  92.  
  93.